var t = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../dist/dialog/dialog")), o = getApp();

Page({
    data: {
        id: 1,
        couponSn: "",
        buyNotice: [],
        packageDetail: [],
        noticeDesc: "",
        priceDesc: "",
        storeId: null,
        offlinePrice: 0,
        orderGoods: {},
        pluginSetting: {}
    },
    onLoad: function(t) {
        var o, e;
        "" !== (null !== (o = t.storeId) && void 0 !== o ? o : "") && this.setData({
            storeId: parseInt(t.storeId)
        }), "" !== (null !== (e = t.couponSn) && void 0 !== e ? e : "") && this.setData({
            couponSn: t.couponSn
        }), this.storeGoodsList();
    },
    onRefund: function(e) {
        var n = this;
        e.currentTarget.dataset.id ? t.default.confirm({
            title: "提示",
            message: "是否确认核销消费券号：".concat(this.data.couponSn)
        }).then(function() {
            var t = o.getNetAddresss("plugin.coupon-store.frontend.store-manage.examineCoupon"), e = {
                cstore_id: n.data.storeId,
                coupon_sn: n.data.couponSn,
                request_type: 2
            };
            o._postNetWork({
                url: t,
                data: e,
                success: function(t) {
                    var o = t.data;
                    1 == o.result ? (console.log(o), wx.showToast({
                        icon: "none",
                        title: o.msg,
                        duration: 1500
                    })) : wx.showToast({
                        icon: "none",
                        title: o.msg,
                        duration: 1500
                    }), setTimeout(function() {
                        wx.navigateBack({
                            delta: 1
                        });
                    }, 1e3);
                },
                fail: function(t) {
                    console.log(t), setTimeout(function() {
                        wx.navigateBack({
                            delta: 1
                        });
                    }, 1e3);
                }
            });
        }).catch(function() {}) : t.default.alert({
            message: "不是适用门店暂时不能核销"
        }).then(function() {
            setTimeout(function() {
                wx.navigateBack({
                    delta: 1
                });
            }, 1e3);
        });
    },
    storeGoodsList: function() {
        var t = this, e = o.getNetAddresss("plugin.coupon-store.frontend.store-manage.examineCoupon"), n = {
            cstore_id: this.data.storeId,
            coupon_sn: this.data.couponSn,
            request_type: 1
        };
        o._postNetWork({
            url: e,
            data: n,
            success: function(o) {
                var e, n, a = o.data;
                1 == a.result ? (console.log(a), t.setData({
                    orderGoods: a.data.order_goods,
                    offlinePrice: a.data.offline_price,
                    buyNotice: a.data.buy_notice,
                    packageDetail: a.data.package_detail,
                    noticeDesc: a.data.notice_desc,
                    priceDesc: a.data.price_desc,
                    pluginSetting: null === (e = a.basic_info) || void 0 === e || null === (n = e.plugin_setting) || void 0 === n ? void 0 : n.coupon_store
                })) : (wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                }), setTimeout(function() {
                    wx.navigateBack({
                        delta: 1
                    });
                }, 1e3));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});